﻿#region Copyright information
// 
// Copyright © 2005-2013 Yongkee Cho. All rights reserved.
// 
// This code is a part of the Biological Object Library and governed under the terms of the
// GNU Lesser General  Public License (LGPL) version 2.1 which accompanies this distribution.
// For more information on the LGPL, please visit http://bol.codeplex.com/license.
// 
// - Filename: ProbabilityTreeNode.cs
// - Author: Yongkee Cho
// - Email: yongkeecho@gmail.com
// - Date Created: 2012-12-08 8:26 AM
// - Last Modified: 2013-01-25 3:59 PM
// 
#endregion
using System;
using System.Collections.Generic;
using System.Linq;

namespace BOL.Algorithms.Classification
{
    public class ProbabilityTreeNode<TClass> : DecisionTreeNodeBase<TClass>
    {
        #region Public properties

        public IDictionary<TClass, double> ProbabilityTable { get; private set; }

        #endregion

        #region Constructor

        public ProbabilityTreeNode(dynamic key, IDictionary<TClass, double> probabilityTable)
            : base((object)key)
        {
            ProbabilityTable = probabilityTable;
        }

        #endregion

        #region Object overriden

        public override string ToString()
        {
            return String.Format("{0}{1}", base.ToString(), String.Join(", ", ProbabilityTable.Select(p => String.Format("p_{0} = {1:0.000}", p.Key, p.Value))));
        }

        #endregion
    }
}